
public class VendingMachine {

	public static Address address;
	
	private Inventory products;
	private Sale order;
	
	public void createSale () {
	    order = new Sale ();
	}
	public void setupPayment (String payType) {
        order.setPayment (payType);
	}
	public void attemptPIN (String guess) {
	    order.pinInput (guess);
	}
    public void addItem (String id) {
        // Add an item to the order.
        order.addItem (products.getAvailableItem (id));
    }
	public boolean makePayment () {
	    if (order.isComplete () && order.isPayable ()) {
	        return order.extractPayment ();
	    } else {
	        System.out.println ("Invalid card or incorrect PIN.");
	    }
	    return false;
	}
	public void dispenseItems () {
	    if (order.isPaid ()) {
	        order.dispenseSoldItems ();
	    }
	}
    public void endSelection () {
        order.isReady = true;
    }
}
